package com.vfa.fishing.animal;

import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

import android.os.Parcel;
import android.util.Log;

import com.vfa.fishing.GameActivity;
import com.vfa.fishing.common.AbstractObject;
import com.vfa.fishing.common.Constant;


public class Moss extends AbstractObject {
    // Constructor
    public Moss(int x,int y,TiledTextureRegion pTextureRegion,int sideApp,int ikind){
        super(x,y,pTextureRegion,sideApp);
        kind = ikind;
        sideAppear = sideApp;
        if(sideAppear == Constant.LEFTSIDE){
            direction = Constant.RIGHT;
        }
        else if(sideAppear == Constant.RIGHTSIDE){
            direction = Constant.LEFT;
        }
        if (kind == 0) {
            speedX = 1;
        }
        else if (kind == 1) {
            speedX = 3;
        }
        iTimeToResetDirect = 0;
        isReset = false;
        this.kindOfObject = Constant.MOSS;
    }
    public Moss(int x, int y, TiledTextureRegion pTextureRegion,  int ikind,int speedx,int speedy,int direct,int iweight,int timetoreset,boolean isreset){
        super(x, y, pTextureRegion);
        isReset = isreset;
        speedX = speedx;
        speedY = speedy;
        kind = ikind;
        direction  = direct;
        weight = iweight;
        iTimeToResetDirect = timetoreset;
        isReset = isreset;
        this.kindOfObject = Constant.MOSS;
    }

    public void update() {

        iTimer = GameActivity.TIMER;

        float X = this.getX();
        float Y = this.getY();

        if (kind == 0) {
            if(!this.checkCollision()) {
                if (direction == Constant.RIGHT) {

                    X += speedX;
                    this.setPosition(X, Y);
                } else if (direction == Constant.LEFT) {
                    X -= speedX;
                    this.setPosition(X, Y);
                }
            }
        } else if (kind == 1) {
            if (!this.checkCollision()) {
                if (direction == Constant.RIGHT) {
                    X += speedX;
                    this.setPosition(X, Y);
                }
                else if (direction == Constant.LEFT) {
                    X -= speedX;
                    this.setPosition(X, Y);
                }

            }
        }
    }

    @Override
    public void Eat() {
        // TODO Auto-generated method stub

    }

    @Override
    public void resetDirection() {
        // TODO Auto-generated method stub
    }

    @Override
    public int getCoin() {
        // TODO Auto-generated method stub
        return Constant.COIN_MOSS;
    }

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        // TODO Auto-generated method stub

    }
}